<template>
    <div>
        <el-dialog title="打币工具" :visible.sync="dialogVisible" :close-on-click-modal="false" :show-close="false">
            <el-form ref="form" :model="formApply" label-width="80px" size="medium">
                <!--                <el-form-item label="币种">-->
                <!--                    <el-select v-model="formApply.coin">-->
                <!--                        <el-option label="ETH" value="ETH"></el-option>-->
                <!--                        <el-option label="HD" value="HD"></el-option>-->
                <!--                    </el-select>-->
                <!--                </el-form-item>-->
                <el-form-item label="合约地址">
                    <el-input v-model="formApply.contractAddress"></el-input>
                </el-form-item>
                <el-form-item label="转出地址">
                    <el-input v-model="formApply.from"></el-input>
                </el-form-item>
                <el-form-item label="秘钥">
                    <el-input type="password" v-model="formApply.privateKey"></el-input>
                </el-form-item>
                <el-form-item label="GasLimit">
                    <el-input v-model="formApply.gasLimit"></el-input>
                </el-form-item>
                <el-form-item label="GasPrice">
                    <el-input v-model="formApply.gasPrice"></el-input>
                </el-form-item>
                <el-form-item label="打币数量">
                    <el-input v-model="formApply.count"></el-input>
                </el-form-item>
                <el-form-item label="接收地址">
                    <el-input v-model="formApply.toAddress"></el-input>
                </el-form-item>
            </el-form>


            <div slot="footer" class="dialog-footer">
                <el-button :disabled="disabled" type="primary" @click="onSubmit">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>

    let api = '/manager/user_balance_record';



    export default {
        name: "Tool",
        data() {
            return {
                dialogVisible: true,
                formApply: {
                    // coin: 'WET',
                    contractAddress:'0xbf2179859fc6d5bee9bf9158632dc51678a4100e', // 合约地址
                    from: "0xd94Eb5f78c5D4d3AE1dcA16C2e41da962729E822", // 转出地址
                    privateKey: '0xf67952b47c271369735f194c50dabb975e1d8b88a6b5b028f6bee6fbc7c08132',
                    gasLimit: 80000,
                    gasPrice: 1,
                    count: 10,
                    toAddress: "0x4ecd259bfa0c873d61150b56f7b3313257df45e7", // 接收地址
                },
                disabled:false,
            }
        },
        mounted() {
            this.eth_util.createAccount()
        },
        methods: {
            onSubmit() {
                this.disabled = true;
                setTimeout( ()=> {
                    this.disabled = false;
                },3000);
                console.log('formApply ==== ', this.formApply);
                this.tool_eth_util.sendTokenTx(this.formApply, (data, params) => {
                    console.log('data ==== ', data);
                    if(data) {
                        if(data.code == 0) {
                            alert('hash = ' + data.data)
                        }else {
                            alert('error = ' + data.message)
                        }
                    }
                });
                // this.tool_eth_util.sendETHTx(this.formApply, (data) => {
                //     console.log('data ==== ', data);
                // });
                // this.tool_eth_util.sendETHTx(this.formApply, (data) => {
                //     console.log('data ==== ', data);
                // });
                // this.$confirm('打币已完成，请勿重复发送，稍后请到链上确认!', '提示', {
                //     confirmButtonText: '确定',
                //     showCancelButton:false,
                //     closeOnClickModal:false,
                //     type: 'warning'
                // }).then(() => {
                //
                // }).catch(() => {
                //
                // });
            },

        },

    }
</script>

<style scoped>

</style>

